Accessing the ARRAY data type and ARRAY elements
If you want to declare a variable based on an array data type (this is declaring an array variable), enter the name of the array data type (e.g. myType
) as data type within the declaration of variables. As alternative you may enter the array specification directly in the declaration of the variable (this is declaring an array variable as well); see var2
and var3
in the following example.
If you want to assign an array variable to another array variable, both must be based on the same data type and the same index subrange. In case of a STRING
base data type, the length must be equal as well.
If you want to use array element in assignments, enter the name of the variable or of the function block (e.g. var1
or TONArr1
) and the array subscript (e.g. 2
) enclosed in brackets (e.g. var1[2]
or TONArr1[30]
). In case of a multi-dimensional array element, separate the array subscripts by the character ,
(e.g. var6[1,2]
). As enhancement to the →IEC-standard, it is also possible to enter each of the array subscripts within []
behind each other (e.g. var6[1][2]
).
You can assign an array element to another array element, if both are based on the same data types.
You may enter an →expression as array subscript but it has to return a value of the →data type DINT
. The entered array subscript must be part of the index subrange. If you enter array subscripts as →constant (e.g. var1[2]
), invalid array subscripts are automatically highlighted as errors by Neuron Power Engineer.
If you are using →variables and/or operators for the array subscripts (e.g. Neuron recommends you to add code to your application (e.g. |
Examples |
---|
|
Displayed array elements The display for an array variable in the Instances view is restricted to the base type. If you wish to insert array elements into the Values of Variables view in order to monitor its values, but these array elements are not provided in the Instance view, just drag the base type into the Values of Variables view and modify the inserted item (complete it by the requested array index). |